package com.mt.mtbusinessmanagementsystem.controller;

import com.github.pagehelper.PageInfo;
import com.mt.mtbusinessmanagementsystem.constant.GeneralConstant;
import com.mt.mtbusinessmanagementsystem.constant.MessageConstant;
import com.mt.mtbusinessmanagementsystem.pojo.dto.*;
import com.mt.mtbusinessmanagementsystem.pojo.entity.*;
import com.mt.mtbusinessmanagementsystem.pojo.view.ProductsClassificationType;
import com.mt.mtbusinessmanagementsystem.service.GeneralService;
import com.mt.mtbusinessmanagementsystem.utils.IsTrue;
import com.mt.mtbusinessmanagementsystem.utils.Result;
import com.mt.mtbusinessmanagementsystem.utils.entry.Entry;
import com.mt.mtbusinessmanagementsystem.utils.product.level.FirstLevel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;

import java.time.LocalDateTime;
import java.util.ArrayList;

@RestController
@Slf4j
@CrossOrigin
@RequestMapping("/general")
public class GeneralController {
    @Autowired
    private GeneralService generalService;
    @GetMapping("/test")
    public String test(){
        return "测试成功";
    }


    /**
     * 实现登录方法
     * @param employee
     * @return
     */
    @PostMapping("/login")
    public Result<LoginDTO> login(@RequestBody Employee employee){
        log.info("目前进行登录操作, 接受到的数据有: {}",employee);
        IsTrue<LoginDTO> isTrue=generalService.login(employee);
        return isTrue.getIsTrue()?Result.success(isTrue.getData()):Result.error(MessageConstant.LOGIN_ILLEGAL);
    }

    /**
     * 增加部门
     * @param dept
     * @return
     */
    @PostMapping("/dept/increase")
    public Result<String> addDept(@RequestBody Dept dept){
        log.info("现在进行增加部门操作, 当前接受到的数据有: {}",dept);
        IsTrue<String> isTrue=generalService.addDept(dept);
        return isTrue.getIsTrue() ?
                Result.success(isTrue.getStr()) :
                Result.error(isTrue.getStr());

    }

    /**
     * 现在进行删除部门操作,并将员工转移到未分配
     * @param deptId
     * @return
     */
    @DeleteMapping("/dept/delete")
    public Result<String> delDept(@RequestParam Integer deptId) {
        log.info("现在进行删除部门操作, 接收到的数据有: {}", deptId);
        IsTrue<String> isTrue = generalService.delDept(deptId);
        return isTrue.getIsTrue() ?
                Result.success(isTrue.getStr()) :
                Result.error(isTrue.getStr());
    }

    /**
     * 修改部门信息, 可以更换主管
     * @param deptDTO 部门信息
     * @return 统一返回格式 Result<String>
     */
    @PutMapping("/dept/update")
    public Result<String> updateDept(@RequestBody DeptDTO deptDTO) {
        log.info("现在进行修改部门信息操作, 接收到的数据: {}", deptDTO);

        // 调用服务层方法
        IsTrue<String> isTrue = generalService.updateDept(deptDTO);

        // 根据 isTrue 的返回结果封装响应
        return isTrue.getIsTrue() ? Result.success(isTrue.getStr()) : Result.error(isTrue.getStr());
    }

    /**
     * 查询部门信息
     * @param pageNumber
     * @param pageSize
     * @return
     */
    @GetMapping("/dept/list")
    public Result<PageInfo<DeptDTO>> deptInfoByList(@RequestParam Integer pageNumber, @RequestParam Integer pageSize){
        log.info("现在进行查询部门信息操作, 接收到的信息有: {} {}",pageNumber,pageSize);
        PageInfo<DeptDTO> pageInfo=generalService.deptInfoByList(pageNumber,pageSize);
        return Result.success(pageInfo);
    }

    /**
     * 通过部门号查询员工
     * @param deptId
     * @return
     */
    @GetMapping("/dept/emp")
    public Result<ArrayList<Employee>> employeeByDept(@RequestParam Integer deptId){
        log.info("通过部门号查询员工, 接收到的信息有: {}",deptId);
        ArrayList<Employee> list=generalService.employeeByDept(deptId);
        return Result.success(list);
    }

    /**
     * 添加员工
     * @param employeeDTO
     * @return
     */
    @PostMapping("/employee/increase")
    public Result<String> addEmployee(@RequestBody EmployeeDTO employeeDTO){
        log.info("现在进行添加员工操作, 接收到的信息有: {}",employeeDTO);
        IsTrue<String> isTrue=generalService.addEmployee(employeeDTO);
        return isTrue.getIsTrue()?
                Result.success(MessageConstant.EMPLOYEE_ADD_SUCCESSFUL):
                Result.error(isTrue.getStr());
    }

    /**
     * 修改员工信息
     * @param employeeDTO
     * @return
     */
    @PutMapping("/employee/put")
    public Result<String> updateEmployee(@RequestBody EmployeeDTO employeeDTO) {
        log.info("现在进行修改员工信息操作, 接收到的信息有: {}", employeeDTO);
        IsTrue<String> isTrue = generalService.putEmployee(employeeDTO);
        return isTrue.getIsTrue() ? Result.success(MessageConstant.UPDATED_SUCCESSFUL) : Result.error(isTrue.getStr());
    }

    /**
     * 修改员工头像
     * @param employeeId
     * @param headFile
     * @return
     */
    @PostMapping("/employee/head/put")
    public Result<String> updateHead(@RequestParam String employeeId,@RequestParam MultipartFile headFile){
        log.info("现在进行修改员工头像的操作,接收到的信息分别是: {} {}",employeeId,headFile);
        String url=generalService.putEmployeeHead(employeeId,headFile);
        return Result.success(url);
    }

    /**
     * 删除员工信息
     * @param employeeDTO
     * @return
     */
    @DeleteMapping("/employee/delete")
    public Result<String> deleteEmployee(@RequestBody EmployeeDTO employeeDTO) {
        log.info("现在进行删除员工信息操作, 接收到的信息有: {}", employeeDTO);
        IsTrue<String> isTrue = generalService.deleteEmployee(employeeDTO);
        return isTrue.getIsTrue() ? Result.success(MessageConstant.DATA_DELETE_SUCCESSFUL) : Result.error(isTrue.getStr());
    }

    /**
     * 查询员工信息
     * @param employeeDTO
     * @return
     */
    @GetMapping("/employee/query")
    public Result<List<EmployeeDTO>> queryEmployee(EmployeeDTO employeeDTO) {
        log.info("现在进行查询员工信息操作, 接收到的信息有: {}", employeeDTO);
        List<EmployeeDTO> employeeList = generalService.queryEmployee(employeeDTO);
        return Result.success(employeeList);
    }

    /**
     * 员工列表
     * @param employeeDTO
     * @return
     */
    @GetMapping("/employee/list")
    public Result<PageInfo<EmployeeDTO>> queryEmployeeList(@RequestBody(required = false) EmployeeDTO employeeDTO){
        log.info("现在进行查询员工列表功能, 接收到信息是: {}",employeeDTO);
        PageInfo<EmployeeDTO> pageInfo=generalService.queryEmployeeList(employeeDTO);
        return Result.success(pageInfo);
    }

    /**
     * 添加客户,如果有公司名会添加公司
     * @param customerDTO
     * @return
     */
    @PostMapping("/customer/increase")
    public Result<CustomerDTO> addCustomer(@RequestBody CustomerDTO customerDTO){
        log.info("现在进行添加客户操作, 信息分别是: {}",customerDTO);
        IsTrue<CustomerDTO> isTrue=generalService.addCustomer(customerDTO);
        return isTrue.getIsTrue()?Result.success(isTrue.getData()):Result.error(isTrue.getStr());
    }

    /**
     * 根据条件查询客户
     * @param customerDTO
     * @return
     */
    @GetMapping("/customer/list")
    public Result<PageInfo<CustomerDTO>> queryCustomerList(@RequestBody CustomerDTO customerDTO){
        log.info("现在进行条件查询客户, 接收到的信息分别是: {}",customerDTO);
        PageInfo<CustomerDTO> pageInfo=generalService.queryCustomerList(customerDTO);
        return Result.success(pageInfo);
    }

    /**
     * 返回查询客户界面查询条件
     * @return
     */
    @GetMapping("/customer/query/condition")
    public Result<Entry<Entry<String,ArrayList<CustomerDTO>>,Entry<String,ArrayList<CustomerDTO>>>> queryCreateAndResponsibleInfo(){
        log.info("返回查询客户界面查询条件");
        Entry<Entry<String,ArrayList<CustomerDTO>>,Entry<String,ArrayList<CustomerDTO>>> entry=generalService.queryCreateAndResponsibleInfo();
        return Result.success(entry);
    }

    /**
     * 根据部门名查询员工
     * @param deptName
     * @return
     */
    @GetMapping("/employee/dept/name")
    public Result<ArrayList<Employee>> employeeByDeptName(@RequestParam String deptName){
        log.info("根据部门名查询员工, 接收到的信息有: {}",deptName);
        ArrayList<Employee> list=generalService.employeeByDeptName(deptName);
        return Result.success(list);
    }

    /**
     * 修改客户信息
     * @param customer
     * @return
     */
    @PutMapping("/customer/put")
    public Result<String> customerPut(@RequestBody Customer customer){
        log.info("现在进行修改客户信息, 接收到的信息有: {}",customer);
        generalService.customerPut(customer);
        return Result.success(MessageConstant.UPDATED_SUCCESSFUL);
    }

    /**
     * 查看客户详细信息
     * @param customerDTO
     * @return
     */
    @GetMapping("/customer/detailed/info")
    public Result<CustomerDTO> customerDetailedInfo(@RequestBody CustomerDTO customerDTO){
        log.info("查看客户详细信息,信息分别是: {}",customerDTO);
        IsTrue<CustomerDTO> isTrue=generalService.customerDetailedInfo(customerDTO);
        return isTrue.getIsTrue()?Result.success(isTrue.getData()):Result.error(isTrue.getStr());
    }

    /**
     * 添加跟进方式
     * @param followMethod
     * @return
     */
    @PostMapping("/follow/method/increase")
    public Result<String> addFollowMethod(@RequestBody FollowMethod followMethod){
        log.info("现在进行添加跟进方式操作, 接收到的信息有: {}",followMethod);
        IsTrue isTrue=generalService.addFollowMethod(followMethod);
        return isTrue.getIsTrue()?Result.success(MessageConstant.DATA_INSERT_SUCCESSFUL):Result.error(isTrue.getStr());
    }

    /**
     * 删除跟进方式
     * @param followMethodId
     * @return
     */
    @DeleteMapping("/follow/method/delete")
    public Result<String> delFollowMethod(@RequestParam Integer followMethodId){
        log.info("现在进行删除跟进方式数据操作,接收到的信息有: {}",followMethodId);
        IsTrue<String> isTrue=generalService.delFollowMethod(followMethodId);
        return isTrue.getIsTrue()?Result.success(String.format(MessageConstant.DATA_DELETE_SUCCESSFUL, GeneralConstant.FOLLOW_METHOD_ID)):Result.error(isTrue.getStr());
    }

    /**
     * 修改跟进方式表数据
     * @param followMethod
     * @return
     */
    @PutMapping("/follow/method/put")
    public Result<FollowMethod> updateFollowMethod(@RequestBody FollowMethod followMethod){
        log.info("现在进行修改跟进方式表数据, 接收到的数据有: {}",followMethod);
        IsTrue<FollowMethod> isTrue=generalService.updateFollowMethod(followMethod);
        return isTrue.getIsTrue()?Result.success(isTrue.getData()):Result.error(isTrue.getStr());
    }

    /**
     * 查询跟进方式表
     * @return
     */
    @GetMapping("/follow/method/list")
    public Result<ArrayList<FollowMethod>> queryFollowMethod(){
        log.info("现在开始查询跟进方式表");
        ArrayList<FollowMethod> list=generalService.queryFollowMethod();
        return Result.success(list);
    }

    /**
     * 增加进展表记录
     * @param followMethodsId
     * @param dateTime
     * @param progressInfo
     * @param fileList
     * @param employeeId
     * @param customerId
     * @return
     */
    @PostMapping("/progress/add")
    public Result<String> addProgress(@RequestParam Integer followMethodsId, @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime dateTime
            , @RequestParam String progressInfo,@RequestParam MultipartFile[] fileList, @RequestParam String employeeId, @RequestParam String customerId){
        log.info("现在进行增加进展表记录操作, 接收到的信息分别是: {}, {}, {}, {}, {}",followMethodsId,dateTime.toString(),progressInfo,employeeId,customerId);
        IsTrue<String> isTrue=generalService.addProgress(followMethodsId,dateTime,progressInfo,fileList,employeeId,customerId);
        return Result.success(MessageConstant.DATA_INSERT_SUCCESSFUL);
    }

    /**
     * 查询进展表信息
     * @param customerDTO
     * @return
     */
    @GetMapping("/progress/query/list")
    public Result<ArrayList<ProgressDTO>> queryProgressList(@RequestBody CustomerDTO customerDTO){
        log.info("现在进行查询进展表信息, 接收到的信息分别是: {}",customerDTO);
        IsTrue<ArrayList<ProgressDTO>> isTrue=generalService.queryProgressList(customerDTO);
        return isTrue.getIsTrue()?Result.success(isTrue.getData()):Result.error(isTrue.getStr());
    }

    /**
     * 增加产品分类数据
     * @param productsClassificationDTO
     * @return
     */
    @PostMapping("/product/class/add")
    public Result<String> addProductClass(@RequestBody ProductsClassificationDTO productsClassificationDTO){
        log.info("现在进行增加产品分类, 信息分别是: {}",productsClassificationDTO);
        IsTrue<String> isTrue=generalService.addProductClass(productsClassificationDTO);
        return isTrue.getIsTrue()?Result.success(MessageConstant.DATA_INSERT_SUCCESSFUL):Result.error(isTrue.getStr());
    }

    /**
     * 查询文件的url
     * @param fileInfo
     * @return
     */
    @GetMapping("/file/url/search")
    public Result searchFileUrl(@RequestBody FileInfo fileInfo){
        log.info("现在查询文件的url，接收到的数据有：{}",fileInfo);
        IsTrue<FileInfo> isTrue=generalService.searchFileUrl(fileInfo);
        return isTrue.getIsTrue()?Result.success(isTrue.getData()):Result.error(isTrue.getStr());
    }

    /**
     * 查询产品分类类型信息
     * @return
     */
    @GetMapping("/product/class/search")
    public Result<ArrayList<FirstLevel>> searchProductsClassificationType() {
        log.info("正在查询产品分类类型信息");
        IsTrue<ArrayList<FirstLevel>> isTrue= generalService.searchProductsClassificationType();
        return isTrue.getIsTrue()?Result.success(isTrue.getData()):Result.error(isTrue.getStr());
    }

    /**
     * 修改产品分类表操作
     * @param productsClassificationType
     * @return
     */
    @PutMapping("/product/class/put")
    public Result<String> putProductsClassification(@RequestBody ProductsClassificationType productsClassificationType){
        log.info("现在进行修改产品分类表操作，信息分别是: {}",productsClassificationType);
        IsTrue<String> isTrue=generalService.putProductsClassification(productsClassificationType);
        return isTrue.getIsTrue()?Result.success(MessageConstant.UPDATED_SUCCESSFUL):Result.error(isTrue.getStr());
    }

    /**
     * 删除产品分类表信息
     * @param productsClassificationType
     * @return
     */
    @DeleteMapping("/product/class/delete")
    public Result<String> delProductsClassification(@RequestBody ProductsClassificationType productsClassificationType){
        log.info("现在进行删除产品分类表操作，信息分别是: {}",productsClassificationType);
        IsTrue<String> isTrue=generalService.delProductsClassification(productsClassificationType);
        return isTrue.getIsTrue()?Result.success(String.format(MessageConstant.DATA_DELETE_SUCCESSFUL, GeneralConstant.EMPTY_STRING)):Result.error(isTrue.getStr());
    }

    /**
     * 增加产品
     * @param id
     * @param productsId
     * @param productsEnglishName
     * @param productsChineseName
     * @param vendorCompanyId
     * @param screenSize
     * @param housingStyling
     * @param brandId
     * @param model
     * @param filmColorType
     * @param filmSurfaceLayerTouchFeel
     * @param shellColor
     * @param productsImageArrayId
     * @param purchasePrice
     * @param salePrice
     * @param saleNumberYearPlan
     * @param saleTotalMoneyYearPlan
     * @param saleProfitYearPlan
     * @param saleNumberYearActual
     * @param saleTotalMoneyYearActual
     * @param saleProfitYearActual
     * @param productsNumber
     * @param productsClassificationTypeId
     * @param productsClassificationTypeName
     * @param employeeId
     * @param deptId
     * @param deptName
     * @param postsId
     * @param postsName
     * @param vendorCompanyChineseName
     * @param vendorCompanyEnglishName
     * @param files
     * @return
     */
    @PostMapping("/product/add")
    public Result<String> addProduct(@RequestParam(required = false) Integer id, @RequestParam(required = false) String productsId
            , @RequestParam(required = false) String productsEnglishName, @RequestParam(required = false) String productsChineseName
            , @RequestParam(required = false) Integer vendorCompanyId, @RequestParam(required = false) String screenSize
            , @RequestParam(required = false) String housingStyling, @RequestParam(required = false) Integer brandId
            , @RequestParam(required = false) String model, @RequestParam(required = false) String filmColorType
            , @RequestParam(required = false) String filmSurfaceLayerTouchFeel, @RequestParam(required = false) String shellColor
            , @RequestParam(required = false) String productsImageArrayId, @RequestParam(required = false) Double purchasePrice
            , @RequestParam(required = false) Double salePrice, @RequestParam(required = false) Integer saleNumberYearPlan
            , @RequestParam(required = false) Double saleTotalMoneyYearPlan, @RequestParam(required = false) Double saleProfitYearPlan
            , @RequestParam(required = false) Integer saleNumberYearActual, @RequestParam(required = false) Double saleTotalMoneyYearActual
            , @RequestParam(required = false) Double saleProfitYearActual, @RequestParam(required = false) Integer productsNumber
            , @RequestParam(required = false) String productsClassificationTypeId,@RequestParam(required = false) String productsClassificationTypeName
            , @RequestParam(required = false) String employeeId,@RequestParam(required = false) Integer deptId
            , @RequestParam(required = false) String deptName,@RequestParam(required = false) Integer postsId
            , @RequestParam(required = false) String postsName,@RequestParam(required = false) String vendorCompanyChineseName
            , @RequestParam(required = false) String vendorCompanyEnglishName,@RequestParam(required = false) MultipartFile[] files){
        ProductsDTO productsDTO= ProductsDTO.builder().id(id).productsId(productsId).productsEnglishName(productsEnglishName).productsChineseName(productsChineseName)
                .vendorCompanyId(vendorCompanyId).screenSize(screenSize).housingStyling(housingStyling).brandId(brandId).model(model)
                .filmColorType(filmColorType).filmSurfaceLayerTouchFeel(filmSurfaceLayerTouchFeel).shellColor(shellColor)
                .productsImageArrayId(productsImageArrayId).purchasePrice(purchasePrice).salePrice(salePrice).saleNumberYearPlan(saleNumberYearPlan)
                .saleTotalMoneyYearPlan(saleTotalMoneyYearPlan).saleProfitYearPlan(saleProfitYearPlan).saleNumberYearActual(saleNumberYearActual)
                .saleTotalMoneyYearActual(saleTotalMoneyYearActual).saleProfitYearActual(saleProfitYearActual).productsNumber(productsNumber)
                .productsClassificationTypeId(productsClassificationTypeId).productsClassificationTypeName(productsClassificationTypeName)
                .employeeId(employeeId).deptId(deptId).deptName(deptName).postsId(postsId).postsName(postsName).vendorCompanyChineseName(vendorCompanyChineseName)
                .vendorCompanyEnglishName(vendorCompanyEnglishName).files(files).build();
        log.info("现在进行增加产品操作, 信息分别是: {}",productsDTO);
        IsTrue<String> isTrue=generalService.addProduct(productsDTO);
        return isTrue.getIsTrue()?Result.success(MessageConstant.DATA_INSERT_SUCCESSFUL):Result.error(isTrue.getStr());
    }

    /**
     * 修改产品
     * @param id
     * @param productsId
     * @param productsEnglishName
     * @param productsChineseName
     * @param vendorCompanyId
     * @param screenSize
     * @param housingStyling
     * @param brandId
     * @param model
     * @param filmColorType
     * @param filmSurfaceLayerTouchFeel
     * @param shellColor
     * @param productsImageArrayId
     * @param purchasePrice
     * @param salePrice
     * @param saleNumberYearPlan
     * @param saleTotalMoneyYearPlan
     * @param saleProfitYearPlan
     * @param saleNumberYearActual
     * @param saleTotalMoneyYearActual
     * @param saleProfitYearActual
     * @param productsNumber
     * @param productsClassificationTypeId
     * @param productsClassificationTypeName
     * @param employeeId
     * @param deptId
     * @param deptName
     * @param postsId
     * @param postsName
     * @param vendorCompanyChineseName
     * @param vendorCompanyEnglishName
     * @param files
     * @return
     */
    @PutMapping("/product/put")
    public Result<String> putProduct(@RequestParam(required = false) Integer id, @RequestParam(required = false) String productsId
            , @RequestParam(required = false) String productsEnglishName, @RequestParam(required = false) String productsChineseName
            , @RequestParam(required = false) Integer vendorCompanyId, @RequestParam(required = false) String screenSize
            , @RequestParam(required = false) String housingStyling, @RequestParam(required = false) Integer brandId
            , @RequestParam(required = false) String model, @RequestParam(required = false) String filmColorType
            , @RequestParam(required = false) String filmSurfaceLayerTouchFeel, @RequestParam(required = false) String shellColor
            , @RequestParam(required = false) String productsImageArrayId, @RequestParam(required = false) Double purchasePrice
            , @RequestParam(required = false) Double salePrice, @RequestParam(required = false) Integer saleNumberYearPlan
            , @RequestParam(required = false) Double saleTotalMoneyYearPlan, @RequestParam(required = false) Double saleProfitYearPlan
            , @RequestParam(required = false) Integer saleNumberYearActual, @RequestParam(required = false) Double saleTotalMoneyYearActual
            , @RequestParam(required = false) Double saleProfitYearActual, @RequestParam(required = false) Integer productsNumber
            , @RequestParam(required = false) String productsClassificationTypeId,@RequestParam(required = false) String productsClassificationTypeName
            , @RequestParam(required = false) String employeeId,@RequestParam(required = false) Integer deptId
            , @RequestParam(required = false) String deptName,@RequestParam(required = false) Integer postsId
            , @RequestParam(required = false) String postsName,@RequestParam(required = false) String vendorCompanyChineseName
            , @RequestParam(required = false) String vendorCompanyEnglishName,@RequestParam(required = false) MultipartFile[] files){
        ProductsDTO productsDTO= ProductsDTO.builder().id(id).productsId(productsId).productsEnglishName(productsEnglishName).productsChineseName(productsChineseName)
                .vendorCompanyId(vendorCompanyId).screenSize(screenSize).housingStyling(housingStyling).brandId(brandId).model(model)
                .filmColorType(filmColorType).filmSurfaceLayerTouchFeel(filmSurfaceLayerTouchFeel).shellColor(shellColor)
                .productsImageArrayId(productsImageArrayId).purchasePrice(purchasePrice).salePrice(salePrice).saleNumberYearPlan(saleNumberYearPlan)
                .saleTotalMoneyYearPlan(saleTotalMoneyYearPlan).saleProfitYearPlan(saleProfitYearPlan).saleNumberYearActual(saleNumberYearActual)
                .saleTotalMoneyYearActual(saleTotalMoneyYearActual).saleProfitYearActual(saleProfitYearActual).productsNumber(productsNumber)
                .productsClassificationTypeId(productsClassificationTypeId).productsClassificationTypeName(productsClassificationTypeName)
                .employeeId(employeeId).deptId(deptId).deptName(deptName).postsId(postsId).postsName(postsName).vendorCompanyChineseName(vendorCompanyChineseName)
                .vendorCompanyEnglishName(vendorCompanyEnglishName).files(files).build();
        log.info("现在进行修改产品操作, 信息分别是: {}",productsDTO);
        IsTrue<String> isTrue=generalService.putProduct(productsDTO);
        return isTrue.getIsTrue()?Result.success(MessageConstant.UPDATED_SUCCESSFUL):Result.error(isTrue.getStr());
    }

    /**
     * 删除产品
     * @param productsDTO
     * @return
     */
    @DeleteMapping("/product/del")
    public Result<String> delProduct(@RequestBody ProductsDTO productsDTO){
        log.info("现在进行删除产品操作, 信息分别是: {}",productsDTO);
        IsTrue<String> isTrue=generalService.delProduct(productsDTO);
        return isTrue.getIsTrue()?Result.success(String.format(MessageConstant.DATA_DELETE_SUCCESSFUL, productsDTO.getId())):Result.error(isTrue.getStr());
    }

    /**
     * 查询产品
     * @param productsDTO
     * @return
     */
    @GetMapping("/product/query")
    public Result<PageInfo<ProductsDTO>> queryProduct(@RequestBody ProductsDTO productsDTO){
        log.info("现在进行查询产品信息, 信息分别是: {}",productsDTO);
        IsTrue<PageInfo<ProductsDTO>> isTrue=generalService.queryProduct(productsDTO);
        return isTrue.getIsTrue()?Result.success(isTrue.getData()):Result.error(isTrue.getStr());
    }

    /**
     * 添加产品数量操作
     * @param productsDTO
     * @return
     */
    @PostMapping("/product/number/add")
    public Result<Products> addProductNumber(@RequestBody ProductsDTO productsDTO){
        log.info("现在添加产品数量操作, 信息分别是: {}",productsDTO);
        IsTrue<Products> isTrue=generalService.addProductNumber(productsDTO);
        return isTrue.getIsTrue()?Result.success(isTrue.getData()):Result.error(isTrue.getStr());
    }

    /**
     * 减少产品数量操作
     * @param productsDTO
     * @return
     */
    @PostMapping("/product/number/decrease")
    public Result<Products> decreaseProductNumber(@RequestBody ProductsDTO productsDTO){
        log.info("现在进行减少产品数量操作, 信息分别是: {}",productsDTO);
        IsTrue<Products> isTrue=generalService.decreaseProductNumber(productsDTO);
        return isTrue.getIsTrue()?Result.success(isTrue.getData()):Result.error(isTrue.getStr());
    }

    /**
     * 增加订单
     * @param mtOrderDTO
     * @return
     */
    @PostMapping("/order/add")
    public Result<String> addMtOrder(@RequestBody MTOrderDTO mtOrderDTO){
        log.info("现在进行增加订单操作, 信息分别是: {}",mtOrderDTO);
        IsTrue<String> isTrue=generalService.addMtOrder(mtOrderDTO);
        return isTrue.getIsTrue()?Result.success(MessageConstant.DATA_INSERT_SUCCESSFUL):Result.error(isTrue.getStr());
    }

    /**
     * 修改订单表信息
     * @param mtOrderDTO
     * @return
     */
    @PutMapping("/order/put")
    public Result<MTOrderDTO> putMtOrder(@RequestBody MTOrderDTO mtOrderDTO){
        log.info("修改订单表信息, 接收到的信息分别是: {}",mtOrderDTO);
        IsTrue<MTOrderDTO> isTrue=generalService.putMtOrder(mtOrderDTO);
        return isTrue.getIsTrue()?Result.success(isTrue.getData()):Result.error(isTrue.getStr());
    }

    /**
     * 查询订单表信息
     * @return
     */
    @GetMapping("/order/list")
    public Result<PageInfo<MTOrderDTO>> queryMtOrderList(@RequestBody MTOrderDTO mtOrderDTO){
        log.info("查询订单表信息");
        IsTrue<PageInfo<MTOrderDTO>> isTrue=generalService.queryMtOrderList(mtOrderDTO);
        return isTrue.getIsTrue()?Result.success(isTrue.getData()):Result.error(isTrue.getStr());
    }

    /**
     * 增加买家卖家信息表
     * @param sellerAndBuyerInfo
     * @return
     */
    @PostMapping("/seller/info/add")
    public Result<String> addSellerInfo(@RequestBody SellerAndBuyerInfo sellerAndBuyerInfo) {
        log.info("新增进行增加卖家买家信息表信息, 接收到的数据有: {}", sellerAndBuyerInfo);
        try {
            IsTrue<String> isTrue = generalService.addSellerInfo(sellerAndBuyerInfo);
            return isTrue.getIsTrue() ?
                    Result.success(MessageConstant.DATA_INSERT_SUCCESSFUL) :
                    Result.error(MessageConstant.DATA_ADD_FAILED);
        } catch (Exception e) {
            log.error("新增卖家买家信息失败: ", e);
            return Result.error(MessageConstant.DATA_ADD_FAILED);
        }
    }

    /**
     * 删除买家卖家信息
     * @param sellerInfoId
     * @return
     */
    @DeleteMapping("/seller/info/del")
    public Result<String> deleteSellerInfo(@RequestParam Integer sellerInfoId) {
        log.info("删除卖家买家信息表信息, 接收到的ID: {}", sellerInfoId);
        try {
            IsTrue<String> isTrue = generalService.deleteSellerInfo(sellerInfoId);
            return isTrue.getIsTrue() ?
                    Result.success(MessageConstant.DATA_DELETE_SUCCESSFUL) :
                    Result.error(MessageConstant.DATA_DELETE_FAILED);
        } catch (Exception e) {
            log.error("删除卖家买家信息失败: ", e);
            return Result.error(MessageConstant.DATA_DELETE_FAILED);
        }
    }

    /**
     * 查询买家卖家信息表 (模糊查询)
     * @param sellerAndBuyerInfo 查询条件
     * @return 查询结果
     */
    @GetMapping("/seller/info/list")
    public Result<List<SellerAndBuyerInfo>> querySellerInfoList(SellerAndBuyerInfo sellerAndBuyerInfo) {
        log.info("查询卖家买家信息表信息, 接收到的查询条件: {}", sellerAndBuyerInfo);
        try {
            IsTrue<List<SellerAndBuyerInfo>> isTrue = generalService.querySellerInfoList(sellerAndBuyerInfo);
            if (isTrue.getIsTrue()) {
                return Result.success(isTrue.getData());
            } else {
                return Result.error(isTrue.getStr());
            }
        } catch (Exception e) {
            log.error("查询卖家买家信息失败: ", e);
            return Result.error("查询失败");
        }
    }

    /**
     * 修改卖家买家信息表
     * @param sellerAndBuyerInfo
     * @return
     */
    @PutMapping("/seller/info/put")
    public Result<SellerAndBuyerInfo> updateSellerInfo(@RequestBody SellerAndBuyerInfo sellerAndBuyerInfo) {
        log.info("接收到修改卖家买家信息的请求, 数据: {}", sellerAndBuyerInfo);
        try {
            IsTrue<String> isTrue = generalService.updateSellerInfo(sellerAndBuyerInfo);
            if (isTrue.getIsTrue()) {
                return Result.success(sellerAndBuyerInfo); // 返回修改后的对象
            } else {
                return Result.error("数据修改失败");
            }
        } catch (Exception e) {
            log.error("修改卖家买家信息失败: ", e);
            return Result.error("数据修改失败");
        }
    }
}
